package com.app.couponsharelife.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.app.couponsharelife.R
import com.app.couponsharelife.ui.listener.OnClickListener

/**
 *Created by xct on 2019/1/21
 *Description:体验官弹窗
 */
class TYGImagDialog (context: Context, themeResId: Int, private val listener: OnClickListener,val type:String) : Dialog(context, themeResId) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_tyg)
        initView()
    }

    private fun initView() {
        when(type){
            "Curriculum"->{
                findViewById<ImageView>(R.id.ivTop).setImageResource(R.drawable.img_hhr_dialogbgtop)
                findViewById<TextView>(R.id.tvContent).text="1、团队奖励、门店返佣权益升级，并新增平级奖励，还有更多惊喜等您发现；"
            }
            else->{
                findViewById<ImageView>(R.id.ivTop).setImageResource(R.drawable.img_tyg_dialogbgtop)
                findViewById<TextView>(R.id.tvContent).text="1、百万分红池、团队奖励、门店返佣等权益已经激活，更多惊喜等您发现；"
            }
        }
        findViewById<ImageView>(R.id.ivCloseDialog).setOnClickListener { dismiss() }
        findViewById<ConstraintLayout>(R.id.dialog_sousuo_butqd).setOnClickListener {
            listener.click(0, "")
            dismiss()
        }
        window!!.setWindowAnimations(R.style.scale_in_alpha_out)
        setCanceledOnTouchOutside(true)

        //设置dialog没有边距
        window!!.decorView.setPadding(0, 0, 0, 0)
        val lp = window!!.attributes
        lp.width = WindowManager.LayoutParams.MATCH_PARENT
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT
        window!!.attributes = lp
    }
}